<template>
  <div class="mainshow-container">
    <div class="add-header">
        <h2 :style="index==0?{color:'#1d95ff'}:{color:'#000000'}" @click="choosePanel(0)">首页轮播图</h2>
        <h2 :style="index==1?{color:'#1d95ff'}:{color:'#000000'}" @click="choosePanel(1)">首页热销品</h2>
        <h2 :style="index==2?{color:'#1d95ff'}:{color:'#000000'}" @click="choosePanel(2)">首页特惠品</h2>
    </div>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
    watch:{
        $route(newV){
            if(newV.fullPath==='/manager/mainShow')
                this.choosePanel(0)
        }
    },
    data(){
        return {
            goodList:[],
            goodMap:{},
            hotGoodList:[],
            discountGoodList:[],
            swipperList:[],
            addHotName:'',
            addDisName:'',
            addSwipperName:'',
            nowImgName:'',
            nowGood:'',
            nowUrl: require('@/assets/preview.png'),
            index:-1
        }
    },
    methods:{
        choosePanel(index){
            if(index==this.index)
                return
            this.index = index
            switch(index){
                case 0:{
                    this.$router.push('/manager/mainShow/swipper')
                    break
                }case 1:{
                    this.$router.push('/manager/mainShow/hot')
                    break
                }case 2:{
                    this.$router.push('/manager/mainShow/discount')
                    break
                }
            }
        },
        del(index){
            this.$delete(this.swipperList,index)
        },
        uploadImg(){
            if(this.swipperList.length<4&&this.nowUrl.indexOf('http://')===0){
                this.swipperList.push({name:this.nowUrl,goodId:this.nowGood})
            }
        },
        completeInput(){
            if(this.nowImgName!='')
                this.nowUrl = this.$http.defaults.baseURL+'/images/'+this.nowImgName
            
        }
    },
    
    mounted(){
        this.choosePanel(0)
    }
}
</script>

<style lang="less">
    .mainshow-container{
        width: 95%;
        height: 95%;
        border-radius: 20px;
        box-sizing: border-box;
        padding: 20px;
        background-color: #ffffff;
        .add-header{
            h2{
                margin-left: 20px;
                margin-right: 20px;
                cursor: pointer;
            }
            display: flex;
            margin-bottom: 20px;
        }
        .add-body{
            background-color: #ffffff;
            width: 95%;
            height: 95%;
            box-sizing: border-box;
            padding: 40px 20px;
            border-radius: 15px;
        }
        .icon-container{
            display: flex;
            flex-direction: column;
            background-color: #efefef;
            border-radius: 20px;
            box-sizing: border-box;
            padding: 20px;
            margin: 20px;
            height: 500px;
            .bottom{
                margin-top: 50px;
                display: flex;
                justify-content: right;
                width: 100%;
                button{
                    border: 0 solid #ffffff;
                    color: #ffffff;
                    background-color: #bb420e;
                    border-radius: 15px;
                    box-sizing: border-box;
                    padding: 5px 20px;
                }
            }
            .img-container{
                display: flex;
                align-items: center;
                .img-item{
                    display: flex;
                    img{
                        width: 200px;
                        border-radius: 20px;
                    }
                    h5{
                        text-align: center;
                    }
                    .delete-img{
                        width: 20px;
                        height: 20px;
                        background-image: url(@/assets/close2.png);
                        background-position: 50%;
                        background-size:cover
                    }  
                    .delete-img:hover{
                        background-image: url(@/assets/close1.png);
                        cursor: pointer;
                    }     
                }
                
                margin-right: 10px;
            }
            .text-container{
                flex: 1;
                img{
                    margin-left: 20px;
                }
                select{
                    width: 20%;
                    box-sizing: border-box;
                    padding: 5px 10px;
                    border: 0.5px solid #a2a2a2;
                    border-radius: 7px;
                    margin-left: 20px;
                }
                .warn-tip{
                    margin-left: 10px;
                    text-align: left;
                    color: #C00000;
                    font-weight: bolder;
                }
                h5{
                    margin: 0;
                    font-weight: 900;
                }
                input{
                    box-sizing: border-box;
                    padding: 5px 10px;
                    border: 0.5px solid #a2a2a2;
                    margin: 20px 0;
                    border-radius: 7px;
                }
                button{
                    border: 0 solid #ffffff;
                    margin-left: 10px;
                    box-sizing: border-box;
                    padding: 10px;
                    background-color: #2c2222;
                    border-radius: 5px;
                    color: #ffffff;
                    font-size: 15px;
                }
                button:hover{
                    background-color: #a2a2a2;
                }
            }
            img{
                width: 150px;
                height: 150px;
                border-radius: 20px;
            }
            
        }
    }
</style>